import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './style.css'
import './styles/modal-theme.css'
import LoadingOverlay from './components/LoadingOverlay.vue'
import { loadingService } from './services/loadingService'
import dialog from './utils/dialog'

const app = createApp(App)

// 注册全局加载组件
app.component('LoadingOverlay', LoadingOverlay)

// 将loading服务挂载到全局属性
app.config.globalProperties.$loading = loadingService

// 将对话框服务挂载到全局属性
app.config.globalProperties.$dialog = dialog
app.config.globalProperties.$alert = dialog.alert.bind(dialog)
app.config.globalProperties.$confirm = dialog.confirm.bind(dialog)
app.config.globalProperties.$success = dialog.success.bind(dialog)
app.config.globalProperties.$error = dialog.error.bind(dialog)
app.config.globalProperties.$warning = dialog.warning.bind(dialog)
app.config.globalProperties.$info = dialog.info.bind(dialog)

app.use(router)
app.mount('#app')
